<%- content_for :action_bar do %>
  <ol>
    <li class="action_bar-item">
      <%= link_to t(".actions.new"), new_admin_user_path, class: "btn text-primary" %>
    </li>
  </ol>
<% end %>

<div class="row justify-content-center">
  <div class="col-lg-12">
    <div class="container">
      <h3 class="page-title">
        <%= t(".title") %>
      </h3>
      <%= form_tag admin_users_path, method: :get, class: 'form-inline' do -%>
        <div class="form-group">
          <label class="mr-1" for="text-user-name"><%= t(".table.email") -%>：</label>
          <%= text_field_tag 'user_email', params[:user_email], class: 'form-control', id: 'text-user-name' %>
        </div>
        <div><%= submit_tag t(".actions.search"), class: 'btn btn-primary' %></div>
      <% end -%>
      <div class="table-responsive">
        <table class="table table-striped">
          <thead>
          <tr>
            <th><%= t(".table.id") %></th>
            <th><%= t(".table.email") %></th>
            <th><%= t(".table.created_at") %></th>
            <th><%= t(".table.current_sign_in_at") %></th>
            <th><%= t(".table.status") %></th>
            <th></th>
          </tr>
          </thead>
          <tbody>
          <% @users.each do |user| %>
            <tr>
              <td><%= user.id %></td>
              <td><%= user.email %></td>
              <td><%= time_tag user.created_at %></td>
              <td><%= time_tag user.current_sign_in_at if user.current_sign_in_at %></td>
              <td>
                <% if user.admin? %>
                    <span class="badge badge-success">
                      <%= t("admin.users.shared.status.admin") %>
                    </span>
                <% end %>
                <% unless user.confirmed? %>
                    <span class="badge badge-warning">
                      <%= t("admin.users.shared.status.pending_confirmation") %>
                    </span>
                <% end %>
                <% if user.pending_reconfirmation? %>
                    <span class="badge badge-warning">
                      <%= t("admin.users.shared.status.pending_reconfirmation") %>
                    </span>
                <% end %>
                <% if user.created_by_invite? && !user.invited_to_sign_up? %>
                    <span class="badge badge-warning">
                      <%= t("admin.users.shared.status.inviting") %>
                    </span>
                <% end %>
                <% if user.access_locked? %>
                    <span class="badge badge-danger">
                      <%= t("admin.users.shared.status.locked") %>
                    </span>
                <% end %>
              </td>
              <td>
                <%= link_to t(".table.actions.show"), admin_user_path(user) %>
              </td>
            </tr>
          <% end %>
          </tbody>
        </table>
      </div>

      <%= paginate @users %>
    </div>
  </div>
</div>
